using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class install_Default : System.Web.UI.Page
{
	protected void Page_Load(object sender, EventArgs e)
	{
		bool foundAdministrators = Roles.GetUsersInRole("Administrators").Length > 0;

		alreadySetupPanel.Visible = foundAdministrators;
		setupPanel.Visible = !foundAdministrators;
	}

	protected void runButton_Click(object sender, EventArgs e)
	{
		if (!Roles.RoleExists("Administrators"))
			Roles.CreateRole("Administrators");

		if (!Roles.RoleExists("Editors"))
			Roles.CreateRole("Editors");

		Membership.CreateUser(userLogin.Text, userPassword.Text, userEmail.Text);
		Roles.AddUserToRoles(userLogin.Text, new string[] { "Administrators", "Editors" });

		BlogEngine.Core.BlogSettings.Instance.Name = blogName.Text;
		BlogEngine.Core.BlogSettings.Instance.Description = blogDescription.Text;
		BlogEngine.Core.BlogSettings.Instance.BlogUrl = blogLocation.Text;
		Response.Redirect(blogLocation.Text);
	}
}
